Overview | Package | Class | Tree | Deprecated | Index | Help |
Java Platform 1.1.7 |
||
PREV CLASS | NEXT CLASS | FRAMES | NO FRAMES | ||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.sun.java.swing.text.AbstractDocument | +--com.sun.java.swing.text.DefaultStyledDocument
Warning: serialized objects of this class will not be compatible with future swing releases. The current serialization support is appropriate for short term storage or RMI between Swing1.0 applications. It will not be possible to load serialized Swing1.0 objects with future releases of Swing. The JDK1.2 release of Swing will be the compatibility baseline for the serialized form of Swing objects.
Inner Class Summary | |
DefaultStyledDocument.ElementBuffer
Class to manage changes to the element hierarchy. |
|
static | DefaultStyledDocument.ElementSpec
Specification for building elements. |
DefaultStyledDocument.SectionElement
Default root element for a document... maps out the paragraphs/lines contained. |
Inner classes inherited from class com.sun.java.swing.text.AbstractDocument | |
AbstractDocument.AbstractElement, AbstractDocument.AttributeContext, AbstractDocument.BranchElement, AbstractDocument.Content, AbstractDocument.DefaultDocumentEvent, AbstractDocument.ElementEdit, AbstractDocument.LeafElement |
Field Summary | |
static int | BUFFER_SIZE_DEFAULT
The default size of the initial content buffer. |
Fields inherited from class com.sun.java.swing.text.AbstractDocument | |
BAD_LOCATION, ContentElementName, ElementNameAttribute, listenerList, ParagraphElementName, SectionElementName |
Constructor Summary | |
DefaultStyledDocument(AbstractDocument.Content c,
StyleContext styles)
Constructs a styled document. |
|
DefaultStyledDocument(StyleContext styles)
Constructs a styled document with the default content storage implementation and a shared set of styles. |
|
DefaultStyledDocument()
Constructs a default styled document. |
Method Summary | |
Style | addStyle(java.lang.String nm,
Style parent)
Adds a new style into the logical style hierarchy. |
AbstractDocument.AbstractElement | createDefaultRoot()
Creates the root element to be used to represent the default document structure. |
java.awt.Color | getBackground(AttributeSet attr)
Gets the background color from an attribute set. |
Element | getCharacterElement(int pos)
Gets a character element based on a position. |
Element | getDefaultRootElement()
Gets the default root element. |
java.awt.Font | getFont(AttributeSet attr)
Gets the font from an attribute set. |
java.awt.Color | getForeground(AttributeSet attr)
Gets the foreground color from an attribute set. |
Style | getLogicalStyle(int p)
Fetches the logical style assigned to the paragraph represented by the given position. |
Element | getParagraphElement(int pos)
Gets a paragraph element. |
Style | getStyle(java.lang.String nm)
Fetches a named style previously added. |
void | insert(int offset,
DefaultStyledDocument.ElementSpec[] data)
Inserts new elements in bulk. |
void | insertUpdate(AbstractDocument.DefaultDocumentEvent chng,
AttributeSet attr)
Updates document structure as a result of text insertion. |
void | removeStyle(java.lang.String nm)
Removes a named style previously added to the document. |
void | removeUpdate(AbstractDocument.DefaultDocumentEvent chng)
Updates document structure as a result of text removal. |
void | setCharacterAttributes(int offset,
int length,
AttributeSet s,
boolean replace)
Sets attributes for some part of the document. |
void | setLogicalStyle(int pos,
Style s)
Sets the logical style to use for the paragraph at the given position. |
void | setParagraphAttributes(int offset,
int length,
AttributeSet s,
boolean replace)
Sets attributes for a paragraph. |
Methods inherited from class java.lang.Object | |
clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait |
Field Detail |
public static final int BUFFER_SIZE_DEFAULT
Constructor Detail |
public DefaultStyledDocument(AbstractDocument.Content c, StyleContext styles)
c
- the container for the content
styles
- resources and style definitions which may
be shared across documentspublic DefaultStyledDocument(StyleContext styles)
styles
- the stylespublic DefaultStyledDocument()
Method Detail |
public Element getDefaultRootElement()
protected void insert(int offset, DefaultStyledDocument.ElementSpec[] data) throws BadLocationException
This method is thread safe, although most Swing methods are not. Please see Threads and Swing for more information.
offset
- the starting offset >= 0
data
- the element datapublic Style addStyle(java.lang.String nm, Style parent)
nm
- the name of the style (must be unique within the
collection of named styles). The name may be null if the style
is unnamed, but the caller is responsible
for managing the reference returned as an unnamed style can't
be fetched by name. An unnamed style may be useful for things
like character attribute overrides such as found in a style
run.
parent
- the parent style. This may be null if unspecified
attributes need not be resolved in some other style.public void removeStyle(java.lang.String nm)
nm
- the name of the style to removepublic Style getStyle(java.lang.String nm)
nm
- the name of the stylepublic void setLogicalStyle(int pos, Style s)
This method is thread safe, although most Swing methods are not. Please see Threads and Swing for more information.
pos
- the offset from the start of the document >= 0
s
- the logical style to assign to the paragraph, null if nonepublic Style getLogicalStyle(int p)
p
- the location to translate to a paragraph
and determine the logical style assigned >= 0. This
is an offset from the start of the document.public void setCharacterAttributes(int offset, int length, AttributeSet s, boolean replace)
This method is thread safe, although most Swing methods are not. Please see Threads and Swing for more information.
offset
- the offset in the document >= 0
length
- the length >= 0
s
- the attributes
replace
- true if the previous attributes should be replaced
before setting the new attributespublic void setParagraphAttributes(int offset, int length, AttributeSet s, boolean replace)
This method is thread safe, although most Swing methods are not. Please see Threads and Swing for more information.
offset
- the offset into the paragraph >= 0
length
- the number of characters affected >= 0
s
- the attributes
replace
- whether to replace existing attributes, or merge thempublic Element getParagraphElement(int pos)
pos
- the starting offset >= 0public Element getCharacterElement(int pos)
pos
- the position in the document >= 0protected void insertUpdate(AbstractDocument.DefaultDocumentEvent chng, AttributeSet attr)
chng
- a description of the document change
attr
- the attributesprotected void removeUpdate(AbstractDocument.DefaultDocumentEvent chng)
chng
- a description of the document changeprotected AbstractDocument.AbstractElement createDefaultRoot()
public java.awt.Color getForeground(AttributeSet attr)
attr
- the attribute setpublic java.awt.Color getBackground(AttributeSet attr)
attr
- the attribute setpublic java.awt.Font getFont(AttributeSet attr)
attr
- the attribute setOverview | Package | Class | Tree | Deprecated | Index | Help |
Java Platform 1.1.7 |
||
PREV CLASS | NEXT CLASS | FRAMES | NO FRAMES | ||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |